package com.qf.cm.dao;

import com.qf.cm.pojo.Branch;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.FetchType;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Description: 公用常量
 * @Data: 2022/9/7 17:35
 * @Pacakge: com.qf.cm.dao
 * @ClassName: BranchDao
 * @Author: fan
 */
@Repository
public interface BranchDao {
    @Select("select * from branch where pid = #{pid}")
    List<Branch> findBranchByPid(@Param("pid") Integer pid );
    @Results(id = "findBranchByBname",value = {
            @Result(column = "bid",property = "bid"),
            @Result(column = "bname",property = "bname"),
            @Result(column = "pid",property = "pid"),
            @Result(column = "updatetime",property = "updatetime"),
            @Result(column = "status",property = "status"),
            @Result(column = "bid",property = "taskplans",
                many = @Many(select = "com.qf.cm.dao.TaskpalnsDao.findTaskplanByBid",fetchType = FetchType.EAGER)
            )
    })
    @Select("select * from branch where bname = #{bname}")
    Branch findBranchByBname(@Param("bname")String bname);
}
